package server;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-2-21
 */
public class EchoServer {
	public static void main(String[] args) {
		ServerSocket ss = null;
		try {
			ss = new ServerSocket(9999);
			Socket s = null;
			while (true) {
				s = ss.accept(); // 阻塞于此
				System.out.println("建立一个用户连接....." + s.getInetAddress());
				Thread t = new Thread(new EchoServiceHandler(s));
				t.start();
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				ss.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
	}
}
